home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 3 / Cream of the Crop 3.iso / utility / btoa52.zip / PORT.MS < prev    next >
Text File  |  1994-04-08  |  3KB  |  72 lines

  1. The EXE file included with this MS-DOS distribution of btoa will run
  2. properly under this operating system. There is no need to mess with the
  3. C sources unless you really want to. For those so inclined, here is how
  4. I ported btoa to MS-DOS.
  5.  
  6. Porting btoa to MS-DOS proved to be fairly easy. The problem that I encountered
  7. is that MS-DOS handles binary files and text files slightly differently.
  8. Most operating systems don't have this problem, since they use a single
  9. character to mark the end of a text line. The initial input file to btoa
  10. is assumed to be a binary file. So is the final output when the encoded
  11. file is decoded. Every other file that btoa uses is a text file. The
  12. problem, then, is to make sure that the right file is thrown into
  13. binary mode at the right time, depending on the process requested --
  14. encoding or decoding.
  15.  
  16. Luckily, this is no great problem. In fact, it can be solved by adding
  17. only 3 lines to the btoa.c source file. None of the other files require
  18. alteration. For those with the Unix-type "patch" utility, I have
  19. provided atob.dif for you, which will autopatch btoa.c for you.
  20.  
  21. If you need to do the port manually, here's how to go about it:
  22.  
  23. [ ] Start a text editor and load btoa.c
  24. [ ] Add the following line to the very top of the file:
  25.     #include <fcntl.h>
  26. [ ] fcntl.h contains the definition for O_BINARY
  27.  
  28. [ ] locate the following if-block in function main():
  29.   if (!error)
  30.   {
  31.     if (diagnosis)
  32.       error = producerepair(infile);
  33.     else if (repair)
  34.       error = performrepair(infile);
  35.     else if (a_to_b)
  36.       error = atob(infile);
  37.     else
  38.       error = btoa(infile, infilename);
  39.   }
  40.  
  41. [ ] The above block calls the major function that btoa is to do (encode,
  42.     decode, or do 1 of 2 repair functions. After you have located it,
  43.     change it so that it reads as follows:
  44.   if (!error)
  45.   {
  46.     if (diagnosis)
  47.       error = producerepair(infile);
  48.     else if (repair)
  49.       error = performrepair(infile);
  50.     else if (a_to_b)
  51.     {
  52.       setmode(fileno(outfile), O_BINARY);
  53.       error = atob(infile);
  54.     }
  55.     else
  56.     {
  57.       setmode(fileno(infile), O_BINARY);
  58.       error = btoa(infile, infilename);
  59.     }
  60.  }
  61.  
  62. [ ] You are now done with the repairs.
  63. [ ] Compile btoa.c , atob.c , and repair.c , then link all 3 obj files
  64.     together to form btoa.exe .
  65.  
  66. --
  67. Duane A. Paulson_
  68. dap@kandy.com  | | _____    The Kandy Shack BBS, est. 1982
  69. dap@netcom.com | |/ / __|  Garden Grove, CA +1 714 636-2667
  70.       --       |   <\__ \   Public Access Usenet/Internet!
  71. Santa Ana, CA  |_|\_\___/ Co-sysop/Programmer. Stop by/Say hi!
  72.